package WaiBao;

import java.util.Arrays;

public class WuXinRong {

    public static void main(String[] args) {
        String[] name = {"小小(班长)", "大大(体育委员)", "乐乐(生活委员)", "乎乎", "张三", "李四", "王五", "赵六", "张飞", "李白", "席慕蓉", "令狐冲",
                "小帅", "小伙", "大和", "王哒", "小狼", "李静", "王金", "欧阳", "乐洗", "闫嘉", "欧豪", "李道", "哈哈", "小兵", "小节", "嘟嘟",
                "胖胖", "武欣荣(学生)"};//考生本人:武欣荣(学生)
        int[] age = {18, 19, 19, 21, 20, 20, 19, 21, 20, 18, 18, 18, 19, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 19, 18, 18, 19};
        double[] score1 = {77, 88, 76, 65, 68, 69, 78, 89, 80, 90, 90, 87, 85, 75, 65, 68, 69, 69, 96, 98, 92, 91, 95, 85, 75, 74, 74, 74, 82, 90};
        double[] score2 = {75, 84, 72, 63, 68, 67, 88, 79, 90, 90, 90, 77, 86, 75, 65, 65, 66, 79, 96, 98, 92, 71, 95, 85, 75, 84, 74, 64, 92, 94};
        double[] score3 = {67, 98, 66, 85, 78, 69, 78, 89, 80, 60, 93, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 76, 84, 73, 71, 82, 95};
        /**
         * 5.给出计算并存储每位学生三门课的总分和算术平均分功能的Java代码。（20分）
         */
//        double sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10,sum11,sum12,sum13,sum14,sum15,
//             sum16,sum17,sum18,sum19,sum20,sum21,sum22,sum23,sum24,sum25,sum26,sum27,sum28,sum29,sum30;
//        double avg1,avg2,avg3,avg4,avg5,avg6,avg7,avg8,avg9,avg10,avg11,avg12,g13,avg14,avg15,avg16,avg17,avg18,
//                avg19,avg20,avg21,avg22,avg23,avg24,avg25,avg26,avg27,avg28,avg29,avg30;
        double sum1;//代表每个学生的总分
        double avg1;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            sum1 = score1[i]+score2[i]+score3[i];
//            avg1 = (sum1*1.0)/3;
//            System.out.println(name[i]+"的总分为:"+sum1);
//            System.out.println(name[i]+"的平均分为:"+avg1);
//        }
        /**
         * 6.给出对每位学生的算术平均分大小进行从高到低排序功能的Java代码，并通过代码输出排名前十位学生的名字。（20分）
         */
        double [] temp = new double[31];
//        for (int i = 0; i < 30; i++) {
//            sum1 = score1[i]+score2[i]+score3[i];
//            avg1 = (sum1*1.0)/3;
//            temp[i] = avg1;
//        }
//
//        for (int i = 0; i < temp.length-1; i++) {
//            for (int j = 0; j < temp.length-i-1; j++) {
//                if(temp[j] < temp[j+1]){
//                    double count = temp[j];
//                    temp[j] = temp[j+1];
//                    temp[j+1] = count;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(temp[i]);
//        }
        /**
         * 7.给出计算班级在这三门课中每门课整体的平均分、标准差以及中位数功能的Java代码。（20分）
         */
        double s1 = 0, s2 = 0, s3 = 0;//计算每门课的平均分
        double b1 = 0, b2 = 0, b3 = 0;//计算标准差
        double z1 = 0, z2 = 0, z3 = 0;//计算中位数
        double sum2 = 0;
        for (int i = 0; i < score1.length; i++) {
            sum2+=score1[i];
        }
        s1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+s1);
        double Sum = 0;
        for (int i = 0; i < score2.length; i++) {
            Sum+=score2[i];
        }
        s2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+s2);
        double sum = 0;
        for (int i = 0; i < score3.length; i++) {
            sum+=score3[i];
        }
        s3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+s3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < score1.length; i++) {
            c1+= (score1[i] - s1)*(score1[i] - s1);
        }
        b1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+b1);

        for (int i = 0; i < score2.length; i++) {
            c2+= (score2[i] - s2)*(score2[i] - s2);
        }
        b2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+b2);

        for (int i = 0; i < score3.length; i++) {
            c3+= (score3[i] - s3)*(score3[i] - s3);
        }
        b3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+b3);

//        Arrays.sort(score1);
//        Arrays.sort(score2);
//        Arrays.sort(score3);
//        z1 =( score1[15]+score1[16])*1.0/2;
//        z2 =( score2[15]+score2[16])*1.0/2;
//        z3 =( score3[15]+score3[16])*1.0/2;
//        System.out.println("生物化学的中位数为:"+z1);
//        System.out.println("微生物学的中位数为:"+z2);
//        System.out.println("人体组织解剖学的中位数为:"+z3);
    }
}
